package a.f.j;

import a.c.d;
import a.c.q;
import a.c.w;
import a.c.z;

public class ab
{
  protected q a;
  public z b;
  protected n c;
  private a.c.n d;
  private final j e = new j()
  {
    public d a(d paramAnonymousd)
    {
      return ab.this.f(paramAnonymousd);
    }
  };
  public static int f;
  public static boolean g;
  
  public ab(q paramq)
  {
    this.a = paramq;
    this.d = paramq.C();
    this.b = new z();
  }
  
  public q a()
  {
    return this.a;
  }
  
  public d a(d paramd)
  {
    d locald = this.a.a(paramd.f(), paramd.e());
    a(paramd, locald);
    i(locald).a(true);
    return locald;
  }
  
  public void a(d paramd1, d paramd2)
  {
    i(paramd1).a(paramd2);
    i(paramd2).a(paramd1);
  }
  
  public d b(d paramd)
  {
    return i(paramd).a();
  }
  
  public o b()
  {
    return new e(this.b);
  }
  
  public void a(n paramn)
  {
    this.c = paramn;
  }
  
  public n c()
  {
    return this.c;
  }
  
  public int d()
  {
    return this.b.size();
  }
  
  public n c(d paramd)
  {
    return i(paramd).d();
  }
  
  public void a(d paramd, n paramn)
  {
    i(paramd).a(paramn);
  }
  
  public void e()
  {
    bb localbb = new bb(this);
    localbb.q();
    localbb.i();
  }
  
  public void f()
  {
    a(this.e);
  }
  
  public void a(j paramj)
  {
    boolean bool = g;
    int i = f;
    this.b = new z();
    if (!bool) {
      if (this.a.m() == 0) {
        return;
      }
    }
    boolean[] arrayOfBoolean = new boolean[this.a.m()];
    a.c.m localm = this.a.w();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      if ((!bool) && (i != 0)) {
        return;
      }
      if (!bool)
      {
        if (arrayOfBoolean[locald.d()] == 0) {
          a(locald, paramj, arrayOfBoolean);
        }
        localm.f();
      }
    } while (i == 0);
    if (!bool) {
      a(null);
    }
  }
  
  public n a(d paramd, j paramj, boolean[] paramArrayOfBoolean)
  {
    boolean bool = g;
    int j = f;
    n localn = new n();
    d locald1 = paramd;
    int i = 1;
    if (i != 0) {
      localn.a(paramd);
    }
    label117:
    while (bool)
    {
      i(paramd).a(localn);
      paramArrayOfBoolean[paramd.d()] = true;
      d locald2 = paramj.a(paramd);
      if (bool) {
        break label135;
      }
      if (j != 0) {
        break label134;
      }
      if (paramArrayOfBoolean[locald2.d()] != 0) {
        if (locald2 == locald1)
        {
          i = 0;
          if (bool) {
            break label117;
          }
          if (j == 0) {}
        }
        else
        {
          throw new RuntimeException("Graph is not Planar !");
        }
      }
      paramd = locald2;
      if (j == 0) {
        break;
      }
    }
    label134:
    this.b.add(localn);
    label135:
    return localn;
  }
  
  public p g()
  {
    return new g();
  }
  
  public void a(p paramp)
  {
    ((g)paramp).a();
  }
  
  public d d(d paramd)
  {
    d locald = paramd.i();
    if (!g) {}
    return locald == null ? paramd.e().h() : locald;
  }
  
  public d e(d paramd)
  {
    d locald = paramd.k();
    if (!g) {}
    return locald == null ? paramd.e().j() : locald;
  }
  
  protected d f(d paramd)
  {
    return d(b(paramd));
  }
  
  public boolean h()
  {
    boolean bool = g;
    int i3 = f;
    a.i.n.a(this, 0, "Planarity Check....");
    q localq = a();
    boolean[] arrayOfBoolean = new boolean[localq.m()];
    int i = 0;
    if (i < localq.m())
    {
      arrayOfBoolean[i] = false;
      i++;
    }
    label184:
    label212:
    int j;
    for (;;)
    {
      if (!bool) {
        if (i3 == 0)
        {
          if (i3 == 0) {
            break;
          }
          if (bool) {
            continue;
          }
          Object localObject1 = b();
          Object localObject2;
          Object localObject3;
          d locald1;
          do
          {
            if (!((o)localObject1).e()) {
              break;
            }
            localObject2 = ((o)localObject1).a();
            if (i3 != 0) {
              break label212;
            }
            localObject3 = ((n)localObject2).a();
            do
            {
              do
              {
                if (!((a.c.m)localObject3).e()) {
                  break label184;
                }
                locald1 = ((a.c.m)localObject3).a();
                if (i3 != 0) {
                  break;
                }
                if (arrayOfBoolean[locald1.d()] != 0)
                {
                  a.i.n.a("Edge " + locald1 + " is in two faces !");
                  return false;
                }
                arrayOfBoolean[locald1.d()] = true;
                ((a.c.m)localObject3).f();
              } while (i3 == 0);
              ((o)localObject1).f();
            } while (bool);
          } while (i3 == 0);
          if (!bool)
          {
            do
            {
              localObject1 = this.a.w();
              while (i3 == 0)
              {
                if (!((a.c.m)localObject1).e()) {
                  break;
                }
                if (!bool)
                {
                  if (arrayOfBoolean[localObject1.a().d()] == 0)
                  {
                    a.i.n.a("Edge " + ((a.c.m)localObject1).a() + " is in no face !");
                    return false;
                  }
                  ((a.c.m)localObject1).f();
                }
              }
            } while (bool);
            localObject1 = b();
            label409:
            do
            {
              do
              {
                if (!((o)localObject1).e()) {
                  break;
                }
                localObject2 = new d[2];
                if (i3 != 0) {
                  break label583;
                }
                localObject3 = ((o)localObject1).a().b();
                do
                {
                  do
                  {
                    if (!((k)localObject3).e()) {
                      break label409;
                    }
                    ((k)localObject3).a((d[])localObject2);
                    if (i3 != 0) {
                      break;
                    }
                    if (localObject2[0].f() != localObject2[1].e())
                    {
                      a.i.n.a("Face is not a cycle: " + ((o)localObject1).a());
                      return false;
                    }
                    ((k)localObject3).f();
                  } while (i3 == 0);
                  ((o)localObject1).f();
                } while (bool);
              } while (i3 == 0);
            } while (bool);
            localObject1 = b();
            do
            {
              do
              {
                if (!((o)localObject1).e()) {
                  break;
                }
                localObject2 = ((o)localObject1).a();
                if (i3 != 0) {
                  break label590;
                }
                localObject3 = ((n)localObject2).a();
                do
                {
                  do
                  {
                    if (!((a.c.m)localObject3).e()) {
                      break;
                    }
                    if (i3 != 0) {
                      break label587;
                    }
                    if (c(((a.c.m)localObject3).a()) != localObject2)
                    {
                      a.i.n.a("Edge " + ((a.c.m)localObject3).a() + " belongs to wrong face!");
                      return false;
                    }
                    ((a.c.m)localObject3).f();
                  } while (i3 == 0);
                  ((o)localObject1).f();
                } while (bool);
              } while (i3 == 0);
            } while (bool);
            localObject1 = b();
          }
          label583:
          label587:
          label590:
          label718:
          label721:
          while (bool) {
            do
            {
              do
              {
                if (!((o)localObject1).e()) {
                  break label721;
                }
                localObject2 = ((o)localObject1).a();
                localObject3 = ((n)localObject2).a();
                do
                {
                  if (!((a.c.m)localObject3).e()) {
                    break;
                  }
                  locald1 = ((a.c.m)localObject3).a();
                  ((a.c.m)localObject3).c();
                  d locald2 = ((a.c.m)localObject3).a();
                  ((a.c.m)localObject3).b();
                  localObject4 = b(locald2);
                  if (bool) {
                    break label718;
                  }
                  if (i3 != 0) {
                    break label716;
                  }
                  if (d((d)localObject4) != locald1)
                  {
                    a.i.n.a("Edge " + locald1 + " in wrong order !");
                    return false;
                  }
                  ((a.c.m)localObject3).f();
                } while (i3 == 0);
              } while (bool);
              ((o)localObject1).f();
            } while (i3 == 0);
          }
          label716:
          j = localq.k();
        }
      }
    }
    int k = localq.m();
    int m = b().k();
    int n = a.a.m.a(localq).length;
    int i1 = 0;
    Object localObject4 = localq.v();
    if (((w)localObject4).e()) {}
    while (bool)
    {
      if (i3 != 0) {
        break label831;
      }
      if (((w)localObject4).d().c() == 0) {
        i1++;
      }
      ((w)localObject4).f();
      if (i3 == 0) {
        break;
      }
    }
    label831:
    int i2 = (k / 2 + 2 * n - j - i1 - m) / 2;
    if (!bool)
    {
      if (i2 == 0) {
        return true;
      }
      a.i.n.a("genus ==  " + i2);
    }
    return false;
  }
  
  public void i()
  {
    boolean bool = g;
    int i = f;
    a.c.m localm = this.a.w();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      if (bool) {
        return;
      }
      if (i != 0) {
        break label79;
      }
      if (!bool)
      {
        if (h(locald)) {
          this.a.a(locald);
        }
        localm.f();
      }
    } while (i == 0);
    if (!bool) {
      label79:
      this.a.a(this.d);
    }
  }
  
  public boolean j()
  {
    boolean bool2 = g;
    int i = f;
    if (!bool2) {
      if (c() == null) {
        return false;
      }
    }
    n localn1 = c();
    boolean bool1 = false;
    o localo = b();
    do
    {
      do
      {
        if (!localo.e()) {
          break;
        }
        n localn2 = localo.a();
        if (!bool2)
        {
          if (localn1 == localn2) {
            bool1 = true;
          }
          localo.f();
        }
      } while (i == 0);
    } while (bool2);
    return bool1;
  }
  
  public String toString()
  {
    boolean bool = g;
    int i = f;
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append("Facelist:\n");
    o localo = b();
    do
    {
      if (!localo.e()) {
        break;
      }
      n localn = localo.a();
      if (!bool)
      {
        if (i != 0) {
          break label115;
        }
        localStringBuffer.append("Face :");
      }
      if (!bool)
      {
        if (localn == this.c) {
          localStringBuffer.append("  --> Outer-Face <---");
        }
        localStringBuffer.append("\n");
        localStringBuffer.append(localn);
        localStringBuffer.append("\n");
        localo.f();
      }
    } while (i == 0);
    label115:
    return localStringBuffer.toString();
  }
  
  public void g(d paramd)
  {
    a(paramd, true);
  }
  
  public void a(d paramd, boolean paramBoolean)
  {
    i(paramd).a(paramBoolean);
  }
  
  public boolean h(d paramd)
  {
    return i(paramd).b();
  }
  
  public void k()
  {
    boolean bool = g;
    int i = f;
    a.i.n.a("CIRCULAR OUTEDGE ORDER");
    w localw = this.a.v();
    label23:
    if (localw.e()) {
      a.i.n.a("Node: " + localw.d());
    }
    label134:
    label135:
    while (bool)
    {
      a.c.m localm = localw.d().n();
      do
      {
        if (!localm.e()) {
          break;
        }
        a.i.n.a("  edge: " + localm.a());
        localm.f();
        if (bool) {
          break label135;
        }
        if (i != 0) {
          break label134;
        }
      } while (i == 0);
      if (bool) {
        break label23;
      }
      localw.f();
      if (i == 0) {
        break;
      }
    }
  }
  
  public void l()
  {
    boolean bool = g;
    int i = f;
    a.i.n.a("SHOWING FACES");
    do
    {
      o localo = b();
      while (i == 0)
      {
        if (!localo.e()) {
          break;
        }
        a.i.n.a("Face: " + localo.a());
        localo.f();
      }
    } while (bool);
  }
  
  protected b_ i(d paramd)
  {
    b_ localb_ = (b_)this.d.get(paramd);
    if (!g) {
      if (localb_ == null)
      {
        localb_ = m();
        this.d.a(paramd, localb_);
      }
    }
    return localb_;
  }
  
  protected b_ m()
  {
    return new b_();
  }
  
  public static class b_
  {
    private d a;
    private boolean b;
    private n c;
    public static int d;
    
    void a(d paramd)
    {
      this.a = paramd;
    }
    
    d a()
    {
      return this.a;
    }
    
    boolean b()
    {
      return this.b;
    }
    
    void a(boolean paramBoolean)
    {
      this.b = paramBoolean;
    }
    
    n d()
    {
      return this.c;
    }
    
    void a(n paramn)
    {
      this.c = paramn;
    }
  }
}


/* Location:           E:\idea\
 * Qualified Name:     a.f.j.ab
 * JD-Core Version:    0.7.0.1
 */